package com.yanqu.road.server.cmd.player;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.BusinessReunionProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.connect.CrossAgentLinkedControl;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

/**
 * @author ：zfr
 * @date ：2022/4/18 18:47
 */
@Cmd(code = CrossProtocol.C_CROSS_RECALL_BIND, desc = "召回绑定")
public class CrossRecallBindCmd implements Command {
    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        BusinessReunionProto.WriteRecallCodeReqCrossMsg reqCrossMsg = BusinessReunionProto.WriteRecallCodeReqCrossMsg.parseFrom(packet.getBytes());
        BusinessReunionProto.WriteRecallCodeCrossReqMsg.Builder crossReqMsg = BusinessReunionProto.WriteRecallCodeCrossReqMsg.newBuilder();
        crossReqMsg.setReqCrossMsg(reqCrossMsg);
        crossReqMsg.setOriServerId(CrossAgentLinkedControl.getLinkedClient(ctx).getServerId());
        crossReqMsg.setOriUserId(packet.getPlayerId());
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_CROSS_RECALL_BIND, crossReqMsg);
        MessageHelper.sendPacket(reqCrossMsg.getReqBindServerId(), 0, message);
    }
}
